package com.aabte.design2.behavioral.chain.v1;

import com.aabte.design2.behavioral.chain.Request;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class Application {

    public static void main(String[] args) {
        Handler endHandler = new EndHandler();
        Handler usernameHandler = new UsernameHandler();
        Handler tokenHandler = new TokenHandler();

        tokenHandler.setNext(usernameHandler);
        usernameHandler.setNext(endHandler);

        Handler finalHandler = tokenHandler;

        finalHandler.handle(Request.builder().username("tom").token("token").build());

        finalHandler.handle(Request.builder().username("tom").token(null).build());
    }

}
